package com.wang.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }

    @RequestMapping("/toMain")
    public String toMain(){
        return "main";
    }

    @RequestMapping("/login")
    public String loginInfo(HttpSession session,String username,String password){

        session.setAttribute("username",username);
        return  "main";
    }


    @RequestMapping("/out")
    public String out(HttpSession session){

        //这个是直接删除session，由于我们的浏览器没有关闭，session会不断地产生,所以不能用这个注销
        //session.invalidate();

        //移除session中的username
        session.removeAttribute("username");

        return  "redirect:/index.jsp";
    }


}
